#include <iostream>
#include <queue>
#include <math.h>
using namespace std;

int main(){
	queue<int> que;
	long int N;
	cin>>N;
	long int arr1[N];
	long int arr2[N]={0};
	for(int i = 0;i < N;i++){
		cin>>arr1[i];
		que.push(arr1[i]);
	}
	int deep = 0;
	int Max = 0;
	int index = 0;
	for(int i = 1;que.size();i++){
		int x = pow(2,deep);
		int y = pow(2,deep+1);
		if(i >= x&&i < y){
			arr2[deep] += que.front();
			cout<<que.front()<<" "<<arr2[deep]<<endl;
			que.pop();
			
		}else{
			i--;
			deep++;
			if(arr2[deep-1] > Max){
				index = deep;
				Max = arr2[deep-1];
			}
		}
	}
	if(arr2[deep] > Max){
		index = deep+1;
	}
	cout<<index<<endl;
	system("pause");
	return 0;
} 
